package config

import (
	"fmt"
	"log"
	"os"

	"github.com/pelletier/go-toml/v2"
)

var Conf = &Config{}

func Init(confgPath string) (err error) {
	data, err := os.ReadFile(confgPath)
	if err != nil {
		fmt.Println("read config file error:", err)
		log.Panicln(err.Error())
		return
	}
	var config Config
	if err = toml.Unmarshal(data, &config); err != nil {
		log.Println(err.Error())
		return
	}
	Conf = &config
	return
}
func GetConf() *Config {
	return Conf
}
